<?php
/**
 * @copyright   Copyright (c) 2017 https://www.sapixx.com All rights reserved.
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      pillar<ltmn@qq.com>
 * 优惠券管理
 */
namespace app\allwin\validate;
use think\Validate;

class Coupon extends Validate{

    protected $rule = [
        'id'         => 'require|number',
        'store_id'   => 'require|number',
        'miniapp_id' => 'require|number',
        'daynum'     => 'require|integer',
        'longtime'   => 'require|integer',
        'ontypes'    => 'require|integer|between:0,1',
        'num'        => 'require|integer',
        'name'       => 'require',
        'size'       => 'require|float',
        'types'      => 'require|integer',
        'discount'   => 'require|integer|between:0,9',
        'weekday'    => 'require|array',
        'howmuch'    => 'require|integer',
        'starttime'  => 'require|date',
        'endtime'    => 'require|date',
        'tips'       => 'require',
        'price'      => 'require|float',
        'pay_price'  => 'require|float',
    ];

    protected $message = [
        'id'         => 'ID丢失',
        'store_id'   => '好店不存在',
        'miniapp_id' => '应用失效',
        'daynum'     => '每天可用次数必须填写',
        'longtime'   => '使用间隔必须填写',
        'ontypes'    => '生效时间必须选择',        
        'num'        => '发行总量必须填写',
        'name'       => '优惠券名称必须填写',
        'size'       => '单张大小必须填写',
        'weekday'    => '每周几可以使用必须填写',
        'howmuch'    => '满多少钱可用',
        'starttime'  => '开始时间必须填写',
        'endtime'    => '结束时间必须填写',
        'tips'       => '规则简述必须填写',
        'types'      => '优惠券必须选择',
        'discount'   => '打多少折扣必须填写',
        'price'      => '单价必须填写',
        'pay_price'  => '购买价必须填写',
    ];

    protected $scene = [
        'sort'    => ['id','sort'],
        'edit'    => ['id','name','longtime','daynum','ontypes','pay_price','num','size','discount','price','weekday','onetime','howmuch','starttime','endtime','tips','types'],
        'apiedit' => ['name','size','discount','price','weekday','onetime','howmuch','starttime','endtime','tips','types'],
    ];
}